var app = new Vue({
    el: '#app',
    data: {
        name: "sss",
        goodsList: [
            {
                name: '一个',
                price: 5,
                idstc: .5
            }, {
                name: '两个',
                price: 51,
                idstc: .5
            },{
                name: '三个',
                price: 10,
            },{
                name: '案例',
                price: 30
            }
        ],
        url: 'https://www.baidu.com',
        message:'时间：' + new Date().toLocaleString(),
        msg:'逆转常规',
        seen: false,
        items: [20,23,18,65,32,19,5,56,41],
        doto: "<h2>aaaa</h2>"
    },
    computed: {
        sortItems: function(){
            return this.items.sort(sortNumber);
        },
        sortGoodsList: function(){
            return sortByKey(this.goodsList,'name');
        }
    },
    methods:{
        reverseMessage: function(){
            this.msg = this.msg.split('').reverse().join('')
        }, 
    }
    
})
//数字排序
function sortNumber(a,b){
    return a-b;
}

//数组对象方法排序:
function sortByKey(data,key){
    return data.sort(function(a,b){
      var x=a[key];
      var y=b[key];
      return ((x<y)?-1:((x>y)?1:0));
   });
}